package com.example.string;

import cn.hutool.core.util.StrUtil;
import org.checkerframework.checker.units.qual.A;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @author csp 2020-12-24
 */
public class StringTest {
    @Test
    public void test(){
        String str = "20201224";
        String substring = str.substring(4, 6);
        System.out.println(substring);
    }

    @Test
    public void test2() {
        System.out.println(String.format("1111111111%s", 123123));
    }

    @Test
    public void test3(){

        String string = "123123123123";
        int i = string.indexOf("31");
        int i1 = string.lastIndexOf("31");
        System.out.println(string.substring(0, i1));
    }
    @Test
    public void test4(){
        String str1 = " `id` int(11) NOT NULL AUTO_INCREMENT,\n" +
                "  `suid` int(11) DEFAULT NULL,\n" +
                "  `signUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `fsid` varchar(100) DEFAULT NULL,\n" +
                "  `docId` varchar(100) DEFAULT NULL,\n" +
                "  `originPdf` varchar(300) DEFAULT NULL,\n" +
                "  `signPdf` varchar(300) DEFAULT NULL,\n" +
                "  `downloadUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `viewUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `createTime` datetime NOT NULL,\n" +
                "  `modifyTime` datetime NOT NULL,\n" +
                "  `isSigned` tinyint(1) NOT NULL DEFAULT '0',\n" +
                "  `orderId` int(11) NOT NULL,\n" +
                "  `status` int(11) NOT NULL DEFAULT '0',\n" +
                "  `type` int(11) DEFAULT NULL COMMENT '0:上上签 1:e签宝',\n" +
                "  `flowId` varchar(100) DEFAULT NULL,\n" +
                "  `version` varchar(4) DEFAULT NULL,\n" +
                "  `handSignPath` varchar(100) DEFAULT NULL COMMENT '候选人手签印章地址',\n" +
                "  `face` tinyint(4) DEFAULT NULL COMMENT '0:人脸 1:短信',\n" +
                "  PRIMARY KEY (`id`),\n" +
                "  KEY `index_orderId_status_isSigned` (`isSigned`,`orderId`,`status`),\n" +
                "  KEY `index_orderId` (`orderId`),\n" +
                "  KEY `ssqsign_suid` (`suid`),\n" +
                "  KEY `ssqsign_status` (`status`),\n" +
                "  KEY `ssqsign_isSigned` (`isSigned`)";

        String str2 = "`id` int(11) NOT NULL AUTO_INCREMENT,\n" +
                "  `suid` int(11) DEFAULT NULL,\n" +
                "  `signUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `fsid` varchar(100) DEFAULT NULL,\n" +
                "  `docId` varchar(100) DEFAULT NULL,\n" +
                "  `originPdf` varchar(300) DEFAULT NULL,\n" +
                "  `signPdf` varchar(300) DEFAULT NULL,\n" +
                "  `downloadUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `viewUrl` varchar(3000) DEFAULT NULL,\n" +
                "  `createTime` datetime NOT NULL,\n" +
                "  `modifyTime` datetime NOT NULL,\n" +
                "  `isSigned` tinyint(1) NOT NULL DEFAULT '0',\n" +
                "  `orderId` int(11) NOT NULL,\n" +
                "  `status` int(11) DEFAULT '0',\n" +
                "  `type` int(11) DEFAULT NULL COMMENT '0:上上签 1:e签宝',\n" +
                "  `flowId` varchar(100) DEFAULT NULL,\n" +
                "  `signResult` int(11) DEFAULT NULL COMMENT 'E签宝-签署结果',\n" +
                "  `resultDescription` varchar(1024) DEFAULT NULL COMMENT 'E签宝-拒签或失败时，附加的原因描述',\n" +
                "  `version` varchar(3) DEFAULT NULL,\n" +
                "  `handSignPath` varchar(100) DEFAULT NULL COMMENT '候选人手签印章地址',\n" +
                "  `face` tinyint(4) DEFAULT NULL COMMENT '0:人脸',";

        Pattern pattern = Pattern.compile("`\\w+`");

        Matcher matcher1 = pattern.matcher(str1);
        Matcher matcher2 = pattern.matcher(str2);
        List<String> column1 = new ArrayList<>();
        List<String> column2 = new ArrayList<>();
        while (matcher1.find()) {
            column1.add(matcher1.group());
        }
        while (matcher2.find()) {
            column2.add(matcher2.group());
        }

        for (String s : column2) {
            if (!column1.contains(s)) {
                System.out.println(s);
            }
        }
    }

    @Test
    public void test1(){
        System.out.println("".split(","));
        boolean allEmpty = !StrUtil.isAllEmpty("", "", "");
        System.out.println(allEmpty);
        System.out.println(StrUtil.hasEmpty("1", "", ""));
        System.out.println(System.getProperty("java.io.tmpdir"));
        System.out.println(Integer.toBinaryString(14));
    }
}
